import { Component } from '@angular/core';
import {UserStore} from "../service/user-store";
import {select, Store} from "@ngrx/store";
import {selectQueryParams} from "../store/selectors/router.selectors";

@Component({
  selector: 'app-user-list',
  templateUrl: './user-list.component.html',
  styleUrls: ['./user-list.component.less']
})
export class UserListComponent {
  routerParams: object = {};
  constructor(public userStore: UserStore, private store: Store) {
    store.pipe(select(selectQueryParams)).subscribe((routerState) => {
      // 处理选择的 router state
      console.log('list routerState', routerState)
      this.routerParams = routerState
    });
  }

  ngOnInit() {

  }

  getUsers() {
     this.userStore.fetchUsers();
  }
  setUsers() {
    this.userStore.setUsers([{
      id: 1,
      name: 'zhang san',
      email: 'q@qq.com'
    }]);
  }
}
